<?php

/*
 * Action - Ruins 0$*
 *
 * Look at the top two cards of your deck. Discard them or put them back in any order.
 */

class Survivors extends Card implements iAction, iDarkAges, iRuin {

    public function __construct() {
        parent::__construct("Survivors", 0);
        $this->undoPlay = false;
        $this->undoBuy = false;
    }

    public function getDescription() {
        return array(
            "Look at the top two cards of your deck. Discard them or put them back in any order.");
    }

    public function play(Game $game, $isRealCard) {

        $cards = $game->removeCardsFromDrawDeck(2);

        if (sizeof($cards) > 0) {
            ScreenDisplay::addScreenMessage($game, true, "look on " . nicePrint($cards), "looks on " . sizeof($cards) . " cards");
            $options = array(new Option(1, "Discard"), new Option(1, "Put back"));
            $output = MySocket::GetUserReply($game, Input_ChooseOne, $options, 1, 1, null, "You look on ".  niceReadableString($game, $cards).". Please choose");

            $answer = $output[0];
            if ($answer == "Discard") {
                $game->discardTempDiscardCards($cards);
                ScreenDisplay::addScreenMessage($game, false, " and discard them", " and discards them");
            } else {
                $output = MySocket::GetUserReply($game, Input_Reorder, $cards, -1, -1, null, "Put cards back in any order");
                ScreenDisplay::addScreenMessage($game, false, ", and put " . nicePrint($output) . " back on top of your deck", ", and puts " . sizeof($output) . " cards on top of his deck");
                $output = array_reverse($output);
                foreach ($output as $p) {
                    $game->putCardOnTopOfDrawDeck($p);
                }
            }
        }
        $game->cardActionFinished();
        return true;
    }

}

?>